home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 5.4 KB | 144 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: TargetCheck.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.6> 9/29/93 KTA Removed TargetCheck(), OpenCDEV(which), CloseCDEV(which),
- # SwitchAddressing(value) SwitchVM(state), SwitchFS(state),
- # SwitchCache(state) because there were buggy and no one
- # was(could) using them
- # <1.0.5> 8/25/93 KTA TargetCheck() - BugFix where turning VM off wasn't handled
- # properly.
- # <1.0.4> 7/15/93 KTA Updated References to tasks in Gestalt.lib whos names were
- # changed. Took out code to turn VM down - SwitchVM(). Took out
- # releasetarget prior to restart if restartNecessary -
- # TargetCheck(). Removed checks for Undef, before checking state.
- # <1.0.3> 6/8/93 NAGA Unmark tasks that are not published
- # <1.0.2> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries 'Output.Lib';
-
- #########################################################################
- # Restart()
- #========================================================================
- # Author: Rick Violet
- # Description: Restarts and reaquires Targets
- # Parameters: None
- # Returns: 1 - Success
- # 0 - Failure
- # Examples: Restart();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 7/14/93 Changed some of the logging and added global restartNecessary := 0;
- #########################################################################
- TASK Restart() begin
- global gLogLevel;
- No_Error := 0;
- Target_Not_Found := 3; #error codes returned by acquireTarget/releaseTarget
- Target_Failure := 1; #error codes returned by acquireTarget/releaseTarget
- Time_to_restart := 7; #Approximate time(in seconds) it might take for a
- #Mac to restart
-
- match[target t:?target_name z:?target_zone]; # Get the target name and zone through unification
- global restartNecessary := 0;
-
- Select[MenuItem t:'Restart' m:[menu t:"Special"]]!; # Select the Restart MenuItem
- if (gLogLevel >= 3)
- begin
- println "Selected the 'Restart' menu item";
- Println "Rebooting CPU";
- end;
-
- # Need a save document dialog handler
-
- result := releaseTarget(); # Release target so VU realizes that the target has been lost.
-
- if (result <> Target_Failure) # Released okay
- begin
- if (gLogLevel >= 5)
- Println "Released target successfully";
-
- wait(Time_to_restart); # Short wait to allow machine to boot.
-
- #do an acquire with the same old target name and zone address
- result := acquireTarget(target_name, target_zone);
-
- while(result = Target_Not_Found) # Keep trying until target is found or some other error is reported
- begin
- result := acquireTarget(target_name, target_zone);
- wait(Time_to_restart - 2); # Wait one more time
- end;
- if (result = No_Error) # Reaquired target successfully
- begin
- # Need to wait till all inits get loaded.
- while not match[menu]; # Match menu may not be a long enough wait
- LogStr("Reaquired target successfully",4);
- return (1);
- end;
- else # Couldn't reaquire target successfully
- begin
- LogStr("!@#$% Couldn't aquire target",1);
- return (0);
- end;
- end;#if released ok
- else
- begin
- LogStr("!@#$% Couldn't release target",1);
- return(0); #error couldn't release target
- end;
- end; # Restart()
-
-
- #########################################################################
- # MatchApplication(logMe,UpdateAppTitle)
- #========================================================================
- # Author: KTA
- # Description: This routine will match the current Application and,
- # if the logMe parameter is 1, will log the current
- # application name by passing it to LogStr(). If a
- # parameter is not passed, the default behavior will
- # log the application's title. This routine will also
- # set the global gAppTitle to the application's title.
- # Output appears in the following format:
- # The current application is "Finder"
- # Parameters: logMe - 1 to print the current application's title
- # 0 not to print the application's title
- # UpdateAppTitle - 1 to update the global AppTitle
- # - 0 not to update global AppTitle
- # Return Value: string holding current application's title
- # Examples: MatchApplication();
- # Assumptions: there is an active application
- #========================================================================
- # History:
- #
- #########################################################################
- TASK MatchApplication(logMe := 1, UpdateAppTitle :=1)
- begin
- match[application t:?theAppTitle];
- if (UpdateAppTitle)
- global gAppTitle := theAppTitle; #to Verify App
-
- if (logMe)
- LogStr("The current application is '{theAppTitle}'");
-
- return(theAppTitle);
- end; # MatchApplication()